package lhc.alg.top100;

/**
 * description:  https://leetcode.cn/problems/container-with-most-water/
 *  盛最多水的容器
 *  双指针把 两层for遭人耻笑
 *
 *  看题解把 我是傻逼
 *
 * author: hongchen.liao
 * date:  2022/7/28
 */
public class _11_Container_With_Most_Water {

    class Solution {
        public int maxArea(int[] height) {
            int l = 0, r = height.length-1;
            int ans = 0;
            while(l < r){
                int area = Math.min(height[l], height[r]) * (r - l);
                ans = Math.max(ans, area);
                if(height[l] <= height[r]){
                    ++l;
                }else{
                    --r;
                }
            }
            return ans;
        }
    }

}
